package simco.framework.gui.swing.comp;

import java.awt.event.ActionListener;
import java.net.URL;
import java.util.ResourceBundle;

import javax.swing.ImageIcon;

import simco.framework.gui.utils.LocalizationUtil;

/**
 * Tato trida reprezentuje dialog zobrazujici informace o aplikaci.
 * 
 * Kod teto tridy byl vytvoren (vygenerovan) v IDE Netbeans.
 * 
 * @author Matej Prokop, mythge@students.zcu.cz
 *
 */
public class AboutDialog extends javax.swing.JDialog 
{
	/**
	 * Reference na bundle s lokalizaci
	 */
	private ResourceBundle locResource;	
	
	/**
	 * Vytvori novy dialog s informacemi o aplikaci
	 * @param parent reference na hlavni okno aplikace
	 */
    public AboutDialog(java.awt.Frame parent) 
    {
        super(parent);
        
        this.locResource = LocalizationUtil.getResource(this.getClass().getSimpleName());
        
        initComponents();
        this.setLocationRelativeTo(parent);
        setVisible(true);
    }

    /**
     * Rozmisti komponenty na dialogu
     */
    private void initComponents() 
    {

        javax.swing.JButton closeButton;
        javax.swing.JLabel jLabel1;
        javax.swing.JLabel authorTitle;
        closeButton = new javax.swing.JButton(locResource.getString("closeButton.label"));
        javax.swing.JLabel appNameLabel = new javax.swing.JLabel();
        javax.swing.JLabel authorNameLabel = new javax.swing.JLabel();
        javax.swing.JLabel author1MailLabel = new javax.swing.JLabel();
        javax.swing.JLabel author2Name = new javax.swing.JLabel();
        javax.swing.JLabel author2MailLabel = new javax.swing.JLabel();
        javax.swing.JLabel appDescriptionLabel = new javax.swing.JLabel();
        javax.swing.JLabel imageLabel = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        authorTitle = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);        
        setTitle(locResource.getString("dialog.title")); // NOI18N
        setModal(true);
        setName("aboutBox"); // NOI18N
        setResizable(false);
        
        closeButton.addActionListener(new ActionListener()
        {
        	public void actionPerformed(java.awt.event.ActionEvent e) 
        	{
        		dispose();
        	}
        });
        closeButton.setName("closeButton"); // NOI18N

        appNameLabel.setFont(appNameLabel.getFont().deriveFont(appNameLabel.getFont().getStyle() | java.awt.Font.BOLD, appNameLabel.getFont().getSize()+4));
        appNameLabel.setText(locResource.getString("application.name")); // NOI18N
        appNameLabel.setName("appName"); // NOI18N

        authorNameLabel.setFont(authorNameLabel.getFont().deriveFont(authorNameLabel.getFont().getStyle() | java.awt.Font.BOLD));
        authorNameLabel.setText(locResource.getString("author1Name.text")); // NOI18N
        authorNameLabel.setName("author1Name"); // NOI18N

        author1MailLabel.setText(locResource.getString("author1Mail.text")); // NOI18N
        author1MailLabel.setName("autor1Mail"); // NOI18N

        author2Name.setFont(author2Name.getFont().deriveFont(author2Name.getFont().getStyle() | java.awt.Font.BOLD));
        author2Name.setText(locResource.getString("author2Name.text")); // NOI18N
        author2Name.setName("author2Name"); // NOI18N

        author2MailLabel.setText(locResource.getString("author2Mail.text")); // NOI18N
        author2MailLabel.setName("author2Mail"); // NOI18N

        appDescriptionLabel.setText(locResource.getString("appDescription.text")); // NOI18N
        appDescriptionLabel.setName("appDescription"); // NOI18N

        String imgLocation = "resources/images/about.png";
		ClassLoader cl = this.getClass().getClassLoader();
		URL imageURL = cl.getResource(imgLocation);
		imageLabel.setIcon( new ImageIcon( imageURL ) );
//        imageLabel.setIcon(resourceMap.getIcon("imageLabel.icon")); // NOI18N
        imageLabel.setName("imageLabel"); // NOI18N
        imageLabel.setPreferredSize(new java.awt.Dimension(120, 149));

        jLabel1.setText(locResource.getString("appWhyThat.text")); // NOI18N
        jLabel1.setName("appWhyThat"); // NOI18N

        authorTitle.setText(locResource.getString("authorsTitle.text")); // NOI18N
        authorTitle.setName("authorsTitle"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(imageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(appNameLabel, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(appDescriptionLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 303, Short.MAX_VALUE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(authorTitle, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(authorNameLabel)
                            .addComponent(author2Name))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(105, 105, 105)
                                .addComponent(closeButton))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(author1MailLabel)
                                    .addComponent(author2MailLabel))))
                        .addGap(49, 49, 49)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(imageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(appNameLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(appDescriptionLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addComponent(authorTitle)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(authorNameLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(author2Name))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(author1MailLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(author2MailLabel)))
                        .addGap(14, 14, 14)
                        .addComponent(closeButton)))
                .addContainerGap())
        );

        pack();
    }
}
